package com.itsci.assignment2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class AddTravel extends Activity{
	private EditText name;
	private EditText price;
	private EditText des;
	private TravelManager traMgr;
	private Button bnt;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.add_travel);
		name = (EditText)findViewById(R.id.editText_addTravel_name);
		price = (EditText)findViewById(R.id.editText_addTravel_price);
		des = (EditText)findViewById(R.id.editText_addTravel_description);
		traMgr = new TravelManager(AddTravel.this, null,null,1);
		bnt = (Button)findViewById(R.id.button_addTravel_save);
		bnt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				TravleBean  tr = new TravleBean(name.getText().toString(),Integer.parseInt(price.getText().toString()),des.getText().toString());
				traMgr.insertTravel(tr);
				Intent gotoListGuide = new Intent(AddTravel.this,ListTravel.class);
				startActivity(gotoListGuide);
			}
		});
		
	}
}
